vec4 lanczosFilter(sampler3D volume, in VOLUME_STRUCT volumeStruct, in vec3 sampleOrg) {
	const int radius = 3;
	vec4 result = getVoxel(volume, volumeStruct, sampleOrg);
	if (radius < 1) return result;
	
	vec3 samplePoint = sampleOrg * volumeStruct.datasetDimensions_;
	vec3 pivotPoint = round(samplePoint);
	vec3 distance = samplePoint - pivotPoint;
	const float eps = 0.001;
	if (length(distance) < eps) return result;

	result.a = 0.0;
	const int width = 2 * radius + 1;
	float PI = 3.1415926535;
	
	vec3 arg;
	vec3 sinPiD = sin(PI * distance);
	vec3 lanczos[width];
	for (int i = -radius; i <= radius; i++) {
		arg = PI * (distance - i);
		for (int dim = 0; dim < 3; dim++) {
			if (arg[dim] != 0.0) {
				lanczos[radius + i][dim] = (radius / (arg[dim] * arg[dim])) * pow(-1,abs(i)) * sinPiD[dim] * sin(arg[dim] / radius);
			}
			else {
				lanczos[radius + i][dim] = 1.0;
			}
		}
	}

	// convolution-sum (3D)
	for (int x = -radius; x <= radius; x++) {
        for (int y = -radius; y <= radius; y++) {
            for (int z = -radius; z <= radius; z++) {
				result.a += getVoxel(volume, volumeStruct, (pivotPoint + vec3(x, y, z)) / volumeStruct.datasetDimensions_).a  
							* lanczos[x + radius].x * lanczos[y + radius].y * lanczos[z + radius].z;
			}
		}
	}

	return result;
}